//消失的数字
//输入：[3,0,1]
//输出：2
class Solution {
    //   将1~N之间的数组相加，然后减去nums数组中的每个数字
    public int missingNumber(int[] nums) {
        int data = nums.length;
        for(int i = 0; i < nums.length; ++i){
            data = data - nums[i] + i;
        }
        return data;
    }

    /*public int missingNumbe(int[] nums) {
        Set<Integer> set = new HashSet<Integer>();
        int n = nums.length;
        for (int i = 0;i<n;i++){
            set.add(nums[i]);
        }
        int missing = -1;
        for (int i = 0;i<=n;i++){
            if(!set.contains(i)){
                missing = i;
                break;
            }
        }
        return missing;
    }*/

}


